home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 012 / abort1.arc / ABORT1_0.ASM next >
Encoding:
Assembly Source File  |  1986-09-08  |  3.8 KB  |  144 lines

  1. ;    ABORT1_0
  2. ;
  3. ;    
  4. ;        Resident program that aborts current process with ^R_shift and returns
  5. ;    to originating process (eg, if run by DOS, returns to DOS).
  6. ;        A more powerful version of ^Bk, which just jams and doesn't allow
  7. ;    recovery (back to DOS or originating program) in some prgrams.
  8. ;    For recalcitrant programs that aren't currently or never did listen to
  9. ;    the keyboard. Also for programs that take dozens of keystrokes to exit 
  10. ;    (like symphony). Use when you want it to exit, not when it wants to exit.
  11. ;        Leaves return code 0Fh, which can be interrogated by BATCH IF and
  12. ;    ERRORLEVEL, and DOS fn 4Dh.
  13. ;        So far it's compatible with Sidekick (can be installed before or
  14. ;    after). Abort detects whether it is loaded and reloading ABORT produces no
  15. ;    action. When coresident with other hooked int9 programs (those activated
  16. ;    by the keyboard, such as sidekick) sometime ABORT cannot tell that it's
  17. ;    already loaded in which case a second attempt to load ABORT will lock up
  18. ;    the machine. It doesn't always happen, so I dont know the whole story yet.
  19. ;    Generally ABORT seems benign, however let me know about any bugs or
  20. ;    improvements.
  21. ;
  22. ;    Assembled with IBM MASM 1.00
  23. ;
  24. ;    From a idea in Breakpt.com, a program by  Edward Batulis (c) 1985,
  25. ;    published in Byte, Sep 86, p127
  26. ;    
  27. ;    Joe Mack,                Sept '86
  28. ;    Dept Chemistry, UMBC
  29. ;    5401 Wilkens Ave
  30. ;    Catonsville,MD,21228
  31. ;    (301)-455-3292 afternoons best
  32. ;    
  33. ;    or MIX BBS, leave a message in "ADV" conference
  34. ;    301-480-0350 1200-8-N-1 (it maybe area code 202- not sure)
  35. ;
  36.  
  37.         page        ,132
  38.         title     ABORT1_0
  39. cseg    segment     para        public    'code'
  40.         assume    cs:cseg,ds:cseg
  41.         org    100h
  42.  
  43. abort    proc
  44.  
  45.         jmp        install
  46.  
  47. ;leave secret notice in early code for mad disassemblers
  48.  
  49. notice    db    'ABORT1_0',01Ah
  50.  
  51. old_int9_vector    label    dword
  52. old_int9_offs        dw        ?
  53. old_int9_seg        dw        ?
  54.  
  55.  
  56. new_int9:
  57.     ;call old keyboard routine by simulating an int
  58.  
  59.     pushf
  60.     call    cs:old_int9_vector
  61.  
  62.     push        es        ;save registers
  63.     push     ax
  64.     push        bx
  65.  
  66.     mov        ax,40h    ;look at keyboard flag1 in ROM BIOS data area
  67.     mov        es,ax
  68.     mov        bx,17h
  69.     mov        al,es:[bx]
  70.     and        al,05h    ;mask all but bit 1, bit 3
  71.     cmp        al,5        ;Ctrl-Right Shift pressed?
  72. ;no, take no action, return to process that was interrupted by the keystroke
  73.     jne        quit        
  74.  
  75. ;if so return to originating process
  76.  
  77.     pop        bx        ;restore registers
  78.     pop        ax
  79.     pop        es
  80.     popf
  81.  
  82.     mov        ah,4Ch    ;dos exit fn
  83.     mov        al,0Fh    ;return code
  84.     int        21h
  85.  
  86. quit:
  87.     pop        bx        ;restore before quitting
  88.     pop        ax
  89.     pop        es
  90.     iret
  91.  
  92. END_OF_RESIDENT_CODE    LABEL    BYTE
  93.  
  94. banner_1    db    'ABORT1_0, Mack 1986',0Dh,0Ah,0Dh,0Ah
  95.         db    'ABORT1_0 installed',0Dh,0Ah
  96.         db    'Resident program, exit anything with ^R_shift combination',0Dh,0Ah 
  97.         db    'Key combination detected by int 9h, exits via DOS fn call 4Ch.',0Dh,0Ah
  98.         db    'Leaves return code 0Fh for batch language and DOS fn call 4Dh.',0Dh,0Ah,'$'                ,0Dh,0Ah,'$'
  99.  
  100. banner_2    db    'ABORT1_0, Mack 1986',0Dh,0Ah,0Dh,0Ah
  101.         db    'ABORT already installed',0Dh,0Ah,'$'
  102.  
  103. install:                ;get keyboard interrupt vector
  104.  
  105.     mov        ah,35h    ;get interrupt vector fn
  106.     mov        al,9        ;int 9
  107.     int        21h
  108.  
  109.     cmp        bx,offset new_int9    ;are we installed yet?
  110.     jne         installz        ;if not, install, else exit
  111.  
  112. ;exit
  113.     mov        dx,offset banner_2    ;write banner_2
  114.     mov        ah,9
  115.     int         21h
  116.     int        20h                ;and exit
  117.     
  118. installz:
  119.     mov        old_int9_offs,bx    ;otherwise, save old keyboard interrupt address
  120.     mov        old_int9_seg,es
  121.  
  122.     mov        dx,offset banner_1    ;print banner_1
  123.     mov        ah,9                ;print string 
  124.     int        21h
  125.  
  126. ;set kbd interrupt to point to new_int9
  127.  
  128.     mov        ah,25h            ;set interrupt fn
  129.     mov        al,9                ;int9
  130.     mov        dx,offset new_int9    ;new address
  131.     int         21h
  132.  
  133. ;terminate and stay partially resident, point to last byte of resident code+1
  134.  
  135.     mov        dx,offset END_OF_RESIDENT_CODE+1
  136.     int        27h
  137.  
  138. abort        endp
  139.  
  140. cseg        ends
  141.             end    abort
  142.  
  143.  
  144.